import java.util.ArrayList;
import java.util.List;

public class Solution853 {
    public int carFleet(int target, int[] position, int[] speed) {
        List<int[]> list=new ArrayList<>();
        for (int i=0;i<position.length;i++){
            list.add(new int[]{position[i],speed[i]});
        }
        list.sort((a,b)->b[0]-a[0]);
        int cur=1,pos=0;
        for (int i=1;i<list.size();i++){
            if ((long)(target-list.get(i)[0])*list.get(pos)[1]>(long)(target-list.get(pos)[0])*list.get(i)[1]){
                cur++;
                pos=i;
            }
        }
        return cur;
    }

    public static void main(String[] args) {
        System.out.println(new Solution853().carFleet(12,new int[]{10,8,0,5,3},new int[]{2,4,1,1,3}));
    }
}
